package ${baseInfo.packageName};

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meibang.framework.common.aspect.PrintLog;
import com.meibang.framework.common.utils.ResultMap;
import ${addDTO.packageName}.*;
import ${serviceInterface.packageName}.${serviceInterface.fileName};
<#if baseService??&&baseService!="">
import ${baseService};
    <#list baseService?split(".") as simpleName>
        <#if !simpleName_has_next>
            <#assign serviceSimpleName>${simpleName}</#assign>
        </#if>
    </#list>
</#if>
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ${tableClass.remark!}
 */
@RestController
@RequestMapping("/")
@Api(tags = {"${tableClass.remark!}"})
public class ${baseInfo.fileName} {

    @Autowired
    private ${tableClass.shortClassName}Service ${tableClass.shortClassName?cap_first}Service;

    @ApiOperation(value = "新增")
    @PrintLog
    @PostMapping("/add")
    public ResultMap<${"Long"}> add(@RequestBody ${tableClass.shortClassName}AddDTO addDTO) {
        return ResultMap.success(${tableClass.shortClassName?cap_first}Service.add(addDTO));
    }

    @ApiOperation(value = "修改")
    @PrintLog
    @PutMapping("/update")
    public ResultMap update(@RequestBody ${tableClass.shortClassName}UpdateDTO updateDTO) {
        ${tableClass.shortClassName?cap_first}Service.update(updateDTO);
        return ResultMap.success();
    }

    @ApiOperation(value = "删除")
    @PrintLog
    @DeleteMapping("/delete/{id}")
    public ResultMap<${"Integer"}> deleteById(@PathVariable("id") Long id) {
        ${tableClass.shortClassName?cap_first}Service.deleteById(id);
        return ResultMap.success();
    }

    @ApiOperation(value = "分页")
    @PostMapping("/page")
    public ResultMap<${"Page"}<${tableClass.shortClassName}${"VO"}>> page(@RequestBody ${tableClass.shortClassName}PageDTO pageDTO) {
        return ResultMap.success(${tableClass.shortClassName?cap_first}Service.page(pageDTO));
    }

    @ApiOperation(value = "列表")
    @PostMapping("/list")
    public ResultMap<${"List"}<${tableClass.shortClassName}${"VO"}>> list(@RequestBody ${tableClass.shortClassName}SearchDTO searchDTO) {
        return ResultMap.success(${tableClass.shortClassName?cap_first}Service.list(searchDTO));
    }
}
